<extend name="Public/base" />
<block name="body">
<section class="content col-xs-10">
    <div class="row">
        <div class="col-xs-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h2 class="box-title">留言管理</h2>
                </div><!-- /.box-header -->
         <script id="editor" type="text/plain" name="content"  style="min-height:300px; width: 100%">{$list.content}</script>
         
            </div><!-- /.box -->
                <div class="box-footer">
                    <button type="submit" id="submit" cid ="{$list.id}" class="btn btn-primary">保存</button>
                    <button type="submit" onclick="history.back()" class="btn btn-default pull-right">返回</button>
                </div>
        </div>
    </div>
</section>


</block>
<block name="script">
    
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript">
     var ue = UE.getEditor('editor');
     //var content = UE.getEditor('editor').getPlainTxt();
     $(function(){

     var url = "{:u('Contact/save')}"
     $('#submit').bind('click',function(){
        var content = UE.getEditor('editor').getContent();
        var id = $(this).attr('cid');
         if(content==""){
            alert('内容不能为空');
         }
         $.ajax({
           url: url,
           type: 'POST',
           dataType: 'json',
           data: {data: content,
                    id : id
                },
           complete: function(xhr, textStatus) {
             //called when complete
           },
           success: function(data, textStatus, xhr) {
             if(data.status == 1){
                alert(data.data);
             }else{
                alert(data.data);
             }
           },
           error: function(xhr, textStatus, errorThrown) {
             //called when there is an error
           }
         });
         
     });

     })

    </script>
</block>